<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        function* gen(a, b, c) {
            let sum1 = yield a + b;
            let sum2 = yield sum1 + c;
            return sum2;
        }
        /* 调用 */
        const g = gen(1, 2, 3);
        const { value: res1 } = g.next();    /* {value:3,done:false} */
        const { value: res2 } = g.next(res1) /* {value:6,done:false} */
        const res = g.next(res2); /* {value:6,done:true}*/
        // console.log(res);


        function* request() {
            const url = 'https://cnodejs.org/api/v1/topics';
            const result = yield fetch(url);
        }
        const req = request();
        req.next().value.then(res => {
            return res.json();
        }).then(json => {
            console.log(json);
        });
        
    </script>
</body>

</html>